package com.han.swagger2markdown.core;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    @ApiModelProperty("错误码")
    private int code;
    @ApiModelProperty("提示信息")
    private String msg;
    @ApiModelProperty("返回值")
    private T result;

    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static Result<Void> success() {
        return new Result<>(0, "SUCCESS");
    }

    public static <T> Result<T> success(T result) {
        return new Result<>(0, "SUCCESS", result);
    }

    public static Result<Void> fail() {
        return new Result<>(-1, "ERROR");
    }

    public static Result<Void> fail(String msg) {
        return new Result<>(-1, "ERROR");
    }

}
